﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace schedule
{
    public partial class Category2 : Form
    {
        private String formType;
        private String categoryName;
        private bool isSearch;
        private bool isCateg2Selected = false;
        

        public Category2()
        {
            InitializeComponent();
            isSearch = false;
        }

        public Category2(bool isSearch)
        {
            InitializeComponent();
            this.isSearch = isSearch;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        public void SetType(String type)
        {
            formType = type;
        }

        public void SetIsSearch(bool isSearch)
        {
            this.isSearch = isSearch;
        }

        public void SetCategoryName(String categoryName)
        {
            this.categoryName = categoryName;
        }

        public String getCategoryName()
        {
            return categoryName;
        }

        public bool getIsCateg2Selected()
        {
            return isCateg2Selected;
        }
        
        private void Category2_Load(object sender, EventArgs e)
        {
            WorkManager wm = WorkManager.Instance();
            if (formType == "study")
            {
                gBox_Category.Text = ">스터디";
                btn_Categ1.Text = wm.categoryNames[0];
                pictureBox1.Image = global::schedule.Properties.Resources.img_english;
                btn_Categ2.Text = wm.categoryNames[1];
                pictureBox2.Image = global::schedule.Properties.Resources.img_math;
                btn_Categ3.Text = wm.categoryNames[2];
                pictureBox3.Image = global::schedule.Properties.Resources.img_programming;
                btn_Categ4.Text = wm.categoryNames[3];
                pictureBox4.Image = global::schedule.Properties.Resources.img_book;
            }
            else if (formType == "sport")
            {
                gBox_Category.Text = ">스포츠";
                btn_Categ1.Text = wm.categoryNames[4];
                pictureBox1.Image = global::schedule.Properties.Resources.img_ball;
                btn_Categ2.Text = wm.categoryNames[5];
                pictureBox2.Image = global::schedule.Properties.Resources.img_basketball;
                btn_Categ3.Text = wm.categoryNames[6];
                pictureBox3.Image = global::schedule.Properties.Resources.img_baseball;
                btn_Categ4.Text = wm.categoryNames[7];
                pictureBox4.Image = global::schedule.Properties.Resources.img_mountain;
            }
            else if (formType == "game")
            {
                gBox_Category.Text = ">게임";
                btn_Categ1.Text = wm.categoryNames[8];
                pictureBox1.Image = global::schedule.Properties.Resources.img_game1;
                btn_Categ2.Text = wm.categoryNames[9];
                pictureBox2.Image = global::schedule.Properties.Resources.img_starcraft;
                btn_Categ3.Text = wm.categoryNames[10];
                pictureBox3.Image = global::schedule.Properties.Resources.img_simcity;
                btn_Categ4.Text = wm.categoryNames[11];
                pictureBox4.Image = global::schedule.Properties.Resources.img_diablo3;
            }

            else if (formType == "culture")
            {
                gBox_Category.Text = ">문화생활";
                btn_Categ1.Text = wm.categoryNames[12];
                pictureBox1.Image = global::schedule.Properties.Resources.img_movie;
                btn_Categ2.Text = wm.categoryNames[13];
                pictureBox2.Image = global::schedule.Properties.Resources.img_food;
                btn_Categ3.Text = wm.categoryNames[14];
                pictureBox3.Image = global::schedule.Properties.Resources.img_shopping;
                btn_Categ4.Text = wm.categoryNames[15];
                pictureBox4.Image = global::schedule.Properties.Resources.img_concert;
            }
        }

        private void btn_Categ1_Click(object sender, EventArgs e)
        {
            if (isSearch == false)
            {
                categoryName = btn_Categ1.Text;
                isCateg2Selected = true;
                this.Close();
            }
            else
            {
                categoryName = btn_Categ1.Text;
                PublicScheduleForm f = new PublicScheduleForm(categoryName);
                DialogResult res = f.ShowDialog();
                if (res == DialogResult.OK || res == DialogResult.Cancel)
                {
                    this.Close();
                }
            }
        }

        private void btn_Categ2_Click(object sender, EventArgs e)
        {
            if (isSearch == false)
            {
                categoryName = btn_Categ2.Text;
                isCateg2Selected = true;
                this.Close();
            }
            else
            {
                categoryName = btn_Categ2.Text;
                PublicScheduleForm f = new PublicScheduleForm(categoryName);
                DialogResult res = f.ShowDialog();
                if (res == DialogResult.OK || res == DialogResult.Cancel)
                {
                    this.Close();
                }
            }
        }

        private void btn_Categ3_Click(object sender, EventArgs e)
        {
            if (isSearch == false)
            {
                categoryName = btn_Categ3.Text;
                isCateg2Selected = true;
                this.Close();
            }
            else
            {
                categoryName = btn_Categ3.Text;
                PublicScheduleForm f = new PublicScheduleForm(categoryName);
                DialogResult res = f.ShowDialog();
                if (res == DialogResult.OK || res == DialogResult.Cancel)
                {
                    this.Close();
                }
            }
        }

        private void btn_Categ4_Click(object sender, EventArgs e)
        {
            if (isSearch == false)
            {
                categoryName = btn_Categ4.Text;
                isCateg2Selected = true;
                this.Close();
            }
            else
            {
                categoryName = btn_Categ4.Text;
                PublicScheduleForm f = new PublicScheduleForm(categoryName);
                DialogResult res = f.ShowDialog();
                if (res == DialogResult.OK || res == DialogResult.Cancel)
                {
                    this.Close();
                }
            }
        }
    }
}
